#include <QApplication>
#include <QMessageBox>
#include "include/login_dialog.h"
#include "include/main_window.h"
#include "include/database_manager.h"
#include <QFile>
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    
    // 设置应用程序信息
    app.setApplicationName("进销存管理系统");
    app.setApplicationVersion("1.0.0");
    app.setOrganizationName("Company");
    app.setOrganizationDomain("company.com");
    
    // 设置应用程序样式
    QFile styleFile(":/styles/style.qss");
    if (styleFile.open(QFile::ReadOnly)) {
        QString styleSheet = QLatin1String(styleFile.readAll());
        app.setStyleSheet(styleSheet);
    }
    
    // 初始化数据库
    if (!DatabaseManager::instance().initializeDatabase()) {
        return -1;
    }
    
    // 显示登录对话框
    LoginDialog loginDialog;
    if (loginDialog.exec() == QDialog::Accepted) {
        // 登录成功，显示主窗口
        MainWindow mainWindow;
        mainWindow.show();
        return app.exec();
    }
    
    return 0;
}
